package kata09.discount;

import java.math.BigDecimal;

/**
 * 3 个 130
 */
public class AGoodsDiscount implements IGoodsDiscountStrategy {

    @Override
    public BigDecimal getGoodsDiscountPrice(int buyNumber, BigDecimal sourcePrice) {
        if(buyNumber >= 3){
            BigDecimal discountPrice = new BigDecimal(130);
            int discountPriceNumber = buyNumber / 3;
            int sourcePriceNumber = buyNumber % 3;
            return discountPrice.multiply(new BigDecimal(discountPriceNumber))
                    .add(sourcePrice.multiply(new BigDecimal(sourcePriceNumber)));

        }
        return sourcePrice.multiply(new BigDecimal(buyNumber));
    }
}
